﻿
using System.Linq;
using System;
using System.Collections.Generic;

namespace HandleSign.Utils
{
    class TimeUtils
    {
        /// <summary>
        /// 计算平均时间
        /// </summary>
        /// <param name="time1"></param>
        /// <param name="time2"></param>
        /// <returns></returns>
        public static DateTime GetRctime(DateTime time1, DateTime time2)
        {
            DateTime time = DateTime.Now;
            List<DateTime> dtList = new List<DateTime>();//signtime.Year,signtime.Month,signtime.Day,signtime.Hour,signtime.Minute,signtime.Second
            dtList.Add(time1);
            dtList.Add(time2);
            //signtime2.Year, signtime2.Month, signtime2.Day, signtime2.Hour, signtime2.Minute, signtime2.Second
            var balanceMillSeconds = dtList.Sum(ent => (ent - time).TotalMilliseconds);
            var count = dtList.Count;
            return time.AddMilliseconds(balanceMillSeconds / count);
        }

    }
}